<head><meta name="viewport" content="user-scalable=no,initial-scale=1,maximum-scale=1">
<meta charset=utf-8>
<style>
body { margin: 0px; }
canvas { width:100%; height:100%; overflow: hidden; }
</style>
<script type="text/javascript" src="../h3du_min.js"></script>
<script type="text/javascript" src="../extras/frame.js"></script>
<script type="text/javascript" src="demoutil.js"></script>
<script type="text/javascript" src="../extras/meshjson.js"></script>
<script type="text/javascript" src="animation.js"></script>
<script type="text/javascript" src="skysphere.js"></script>
</head>
<body>
<canvas id=canvas></canvas>
<script id="demo">
/* global H3DU, createSkysphere, makeFloor, rotateVec */
// <!--
/*
 Any copyright to this file is released to the Public Domain.
 http://creativecommons.org/publicdomain/zero/1.0/
 If you like this, you should donate
 to Peter O. (original author of
 the Public Domain HTML 3D Library) at:
 http://peteroupc.github.io/
*/

  // Create the 3D scene; find the HTML canvas and pass it
  // to Scene3D.
  var scene = new H3DU.Scene3D(document.getElementById("canvas"));
  scene.setClearColor("white");
  var sub = new H3DU.Batch3D();
  var loader = new H3DU.TextureLoader();
  sub.getLights().setDirectionalLight(0, [0, -3, 1.2], [1, 1, 1]);
  sub.getLights().setDirectionalLight(1, [0, 3, 1.2], [0.6, 0.6, 0.6]);
  loader.loadAndMapTexturesAll([
    "461223191.jpg",
    "bluebackground.png"
  ], scene).then(function(results) {
    "use strict";
    var mesh = null;
    var skysphere = createSkysphere(100, results[1]);
    skysphere.getTransform().setRotation(90, 1, 0, 0);
    sub.addShape(
    new H3DU.Shape(makeFloor(-5, -5, 10, 10, 1)).setTexture(results[0]));
    mesh = H3DU.Meshes.createSphere(0.5);
    sub.addShape(new H3DU.Shape(mesh).setColor("red").setPosition(1.5, 0, 0.5));
    mesh = H3DU.Meshes.createClosedCylinder(0.5, 0.5, 1);
    sub.addShape(new H3DU.Shape(mesh).setColor("yellow").setPosition(0, 1.5, 0));
    mesh = H3DU.Meshes.createCylinder(0.5, 0, 1);
    sub.addShape(new H3DU.Shape(mesh).setColor("blue").setPosition(0, -1.5, 0));
    mesh = H3DU.Meshes.createTorus(0.2, 0.5);
    sub.addShape(new H3DU.Shape(mesh).setColor("rebeccapurple").setPosition(-1.5, 0, 0.2));
  });

  var timer = {};
  var fc = new H3DU.FrameCounterDiv(scene);
  H3DU.renderLoop(function(time) {
    "use strict";
    sub.perspectiveAspect(45, 1, 1000);
    var angle = 360 * H3DU.getTimePosition(timer, time, 6000);
    sub.setLookAt(rotateVec([0, -3, 1.2], angle), [0, 0, 0], [0, 0, 1]);
    fc.update();
    scene.render(sub);
  });
// -->
</script>
</body>
